package com.code.zg.news.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.os.Process;

import com.code.zg.news.app.App;
import com.code.zg.news.utils.manager.ActivityManager;

/**
 * Created by zhanggang on 2017/2/22.
 */

public class ApkUtils {
    public static void exitApp(){
        try {
            ActivityManager.getInstance().finishAll();
            System.exit(0);
            Process.killProcess(Process.myPid());
            android.app.ActivityManager systemService = (android.app.ActivityManager) App.getInstance().getSystemService(Context.ACTIVITY_SERVICE);
            systemService.killBackgroundProcesses(App.getInstance().getPackageName());
        }catch (Exception e){}
    }
    /**
     * 检查是否有可用网络
     */
    public static boolean isNetworkConnected() {
        ConnectivityManager connectivityManager = (ConnectivityManager) App.getInstance().getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
        return connectivityManager.getActiveNetworkInfo() != null;
    }
}
